﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Cofe.Core.Actions;
using Cofe.Core.Dynamic;
using Cofe.Core.Entry;
using Cofe.Core.EntryType;
using Cofe.Core.Filter;
using Cofe.Core.Implements;
using Cofe.Core.Interfaces;
using Cofe.Core.Logger;
using Cofe.Core.Property;
using Cofe.Core.Script;
using Cofe.Core.Security;
using Cofe.Core.Session;
using Cofe.Core.Tasks;
using Cofe.Core.Utils;
using Cofe.Web;

namespace Cofe.Core
{
    public class RegisterModule : RegisterModuleBase
    {
        public override void PreRegister()
        {
            base.PreRegister();
            CofeServices.resetProperties();
        }

        public RegisterModule()
        {            
            //Add all services here.
            base.registerServices(
                new ManualServiceImporter(),            //For import Services
                new ServiceLocater(),                   //For locating services               
                new DummyLogger(),
                new LoggerEventListener.Factory(),      //Route CofeSystemInfoEvents to EventLogger ---> DebugLogger / ConsoleLogger etc.
                new CachePropertyDefinitions(),
                new CofePropertyDefinitions(),
                new CofeDirectoryPropertyDefinitions(),
                new CofeItemPropertyDefinitions(),
                new CofeStreamPropertyDefinitions(),
                new CofeIconPropertyDefinitions(),          //Provide a list of properties,
                new CofeEntryLinkPropertyDefinitions(),
                new CofeEntryListPropertyDefinitions(),
                new CofeEntryTypePropertyDefinitions(),

                new PropertyDictionary(),               //For provide information about properties, contains all supported PropertyDefinitions.                
                //new SecondaryPropertyProviderManager(), //Helper class for SecondaryPropertyProvider *Removed
                //new PropertyHostFactory()             //Generate PropertyHost. * Removed                
                new EntryOptionFilterParser(),
                new ParamParser(),

                new EntryXmlSerializer(),
                new EntryJObjectSerializer(),

                //Path Parsing
                new CofePathParser(),
                new CofePathParserManager(),
                new ParseOnly(),
                new SecurityManager(),
                new UserManager(),

                new VolumeRegistrar(),                  //All volume are registered here.
                new VolumeRegistrarBehaviorManager(),
                new VolumeRegistrarGetRootBehavior(),
                new EntryTypeVolumeFactory(),           //This auto register itselves to VolumeRegistrar.
                
                new ParsePathPrimaryPPRegenerator(),
                new NotExistsPrimaryPPRegenerator(),
                new EntryListPropertyProvider.Regenerator(),
                

                new EntryConstructor(),                 //Construct Entry.
                new CofeSettings(),                     //Central place for storing settings.
                new ListActionProvider.Factory(),       //Provide List Action if the property provider implemented ListCore/Async.
                new SearchActionProvider.Factory(),
                new FilterConstructor(),                //Construct a filter from string, using the embedded factories (e.g. CoreFilterFactory / PropertyEntryFilter.Factory).
                new CofeFilterFactory(),                //Construct a number of entry and option filters.                
                new PropertyEntryFilter.Factory(),      //Construct  PropertyEntryFilter
                new CofeActionProvider.Factory(),       //Provide a number of common actions. (e.g. create, delete)
                new CofePropertyProvider.Factory(),      //Provide a number of common properties (e.g. name)     
                new EntryTypeSecondaryPP.Factory(),
                new CoreEntryLinkContainerBehavior.SecondaryPPFactory(),

                new EntryListVolumeFactory(),
                new EventHub(),

                //Transfer
                new CopyStream(),                       //Transfer files which support OpenReadAsync.
                new CopyDirectoryContent(),              //Transfer directory contents that support ListAsync.
                //new LinkEntryToCustomEntryList(),
                new LinkEntryTransfer(),
                new RenameEntry(),

                new CofeTransferManager(),

                new CofeDynamicInterfaceManager(),
                new CofeInterfaceProvider(),
                new CofeEntryLinkInterfaceProvider(),

                new MemoryPropertyCache.Factory(),       //Create PropertyCache for PropertyHost.

                new CofeTaskManager(),

                //PropertyHost
                new PropertyBehaviorManager.Factory(),   //PropertyHost.Behaviors, Manage the following Get/Set/List Behavior.
                new GetFirst(), new GetAggregated(), new GetFirstHandled(), new GetCacheOnly(), new GetMinMax(),
                new SetFirst(), new SetAggregated(), new SetFirstHandled(), new SetCacheOnly(), new SetIgnoreCache(),
                new ListAllSupported(),
                new PropertyCacheUpdater(),

                new EntryTypeInfoManager(),
                new EntryListRegistrar(),


                //Script
                new ScriptServices()

                );      
        }

      
    }
}
